package com.ayu.envdemo.controller;

import com.alibaba.fastjson.JSONObject;
import com.ayu.envdemo.entity.DeviceMonitorMongodb;
import com.ayu.envdemo.service.DeviceMongoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 徐林玉
 * @Description MongdbTestController
 * @Date 2023/2/20 14:46
 * @Version 1.0
 */

@RestController
@RequestMapping("api/mongodb")
@Api(tags = "mongodb调用接口")
@Slf4j
public class MongdbTestController {


    private final DeviceMongoService deviceMongoService;

    @Autowired
    public MongdbTestController(DeviceMongoService deviceMongoService) {
        this.deviceMongoService = deviceMongoService;
    }

    @ApiOperation(value = "插入数据")
    @PostMapping("save")
    public void saveData(@RequestBody DeviceMonitorMongodb data)  {


        log.info("thingsboard调用外部API:");
        log.info("data数据:");
        log.info(JSONObject.toJSONString(data));

        deviceMongoService.save(data);

    }



}
